<cfcomponent output="false">

	<cffunction name="init" access="public" returntype="EasyBlogBootstrapper" output="false" >
		<cfargument name="target" type="any" required="true" />
		
		<cfset variables.target = arguments.target />
		
		<cfreturn this/>
	</cffunction>
	
	<cffunction name="run" access="public" returntype="void" output="false" >
		<cfscript>
		var service = "";
		var easyBlog = expandPath( '#variables.target.basepath#/config/EasyBlog.xml.cfm' );
		var modelGlue = expandPath( '#variables.target.basepath#/config/MgConfig.xml.cfm' );
		var config = {};
		
		trace( type="Information", inline="true", text="Put configuration...");
		config.dsnname =		getProfileString( variables.target.config, 'datasource', 'name' );
		config.dsnusername =	getProfileString( variables.target.config, 'datasource', 'username' );
		config.dsnpassword =	getProfileString( variables.target.config, 'datasource', 'password' );
		
		config.root = variables.target.basepath;
		
		// create modelglue configuration
		trace( type="Information", inline="true", text="Create modelglue service factory...");
		service = createServiceFactory( modelGlue, config );
		
		// add parent to modelglue
		trace( type="Information", inline="true", text="Create service factory...");
		service.getNextParent( service ).setParent( createServiceFactory( easyBlog, config ) );
		
		trace( type="Information", inline="true", text="Store framework..." );
		variables.target.store( service );
		
		</cfscript>
	</cffunction>
	
	<!--- coldspring loader utility --->
	<cffunction name="createServiceFactory" access="private" output="false" >
		<cfargument name="serviceDefinition" type="xml" required="true" />
		<cfargument name="defaultProperties" type="struct" required="false" default="#structNew()#"/>
		
		<cfset var serviceFactory = createObject( 'component' , 'coldspring.utils.BeanFactory' ).init( structNew(), arguments.defaultProperties ) />
		
		<cfset serviceFactory.loadBeansFromDynamicXmlFile( arguments.serviceDefinition, arguments.defaultProperties ) />
		
		<cfreturn serviceFactory />
	</cffunction>

</cfcomponent>